<%@ include file="/common/taglibs.jsp"%>

<title><fmt:message key="personDetail.title"/></title>
<content tag="heading"><fmt:message key="personDetail.heading"/></content>

<spring:bind path="person.*">
    <c:if test="${not empty status.errorMessages}">
    <div class="error">
        <c:forEach var="error" items="${status.errorMessages}">
            <img src="<c:url value="/images/iconWarning.gif"/>"
                alt="<fmt:message key="icon.warning"/>" class="icon" />
            ${error}<br />
        </c:forEach>
    </div>
    </c:if>
</spring:bind>

<c:import url="personFormCommon.jsp"/>

<c:if test="${person.personId != null && person.primaryPerson }">
 	<input type="button" value="Add Dependents"
 		name="addRelationship" onclick="javascript:location.href='editRelationship.html?primaryPersonId=${person.personId}';"/>

	<display:table name="person.personRelations" cellspacing="0" cellpadding="0" requestURI=""
	    id="personList" pagesize="25" class="table personList" export="true">

	<display:column titleKey="person.personId" sortable="true" sortProperty="relatedPerson.personId">
         	<c:set var="editurl" value="editRelationship.html?primaryPersonId=${personList.person.personId}&personId=${personList.relatedPerson.personId}"/>
         <a href="${editurl}">${personList.relatedPerson.personId}</a>
	</display:column>
	    <display:column property="relationshipType.relationshipType" escapeXml="true" sortable="true" sortProperty="relationshipType.relationshipType"
	         titleKey="person.relationshipType">
		</display:column>
	    <display:column property="relatedPerson.firstName" escapeXml="true" sortable="true"
	         titleKey="person.firstName"/>
	    <display:column property="relatedPerson.lastName" escapeXml="true" sortable="true"
	         titleKey="person.lastName"/>
	    <display:column property="relatedPerson.email" escapeXml="true" sortable="true"
	         titleKey="person.email"/>
	    <display:column property="relatedPerson.phoneHome" escapeXml="true" sortable="true"
	         titleKey="person.phoneHome"/>
	    <display:column property="relatedPerson.phoneMobile" escapeXml="true" sortable="true"
	         titleKey="person.phoneMobile"/>
	    <display:column property="relatedPerson.gender" escapeXml="true" sortable="true"
	         titleKey="person.gender"/>
	    <display:column escapeXml="false" sortable="false" titleKey="person.roles">
	    	<table>
			<c:forEach var="psor" items="${personList.relatedPerson.personSubOrgRoles}">
		        <tr>
		          <td>${psor.role.name}</td>
		          <td>${psor.subOrg.name}</td>
		        </tr>
      		</c:forEach>
			</table>
	    </display:column>
	    <display:setProperty name="paging.banner.item_name" value="person"/>
	    <display:setProperty name="paging.banner.items_name" value="persons"/>
	</display:table>

<!--
	<display:table name="person.memberInformations" cellspacing="0" cellpadding="0" requestURI=""
	    id="membershipList" pagesize="25" class="table personList" export="true">

	    <display:column property="yearOfMembership" escapeXml="true" sortable="true"
	         titleKey="memberInformation.yearOfMembership"/>
	    <display:setProperty name="paging.banner.item_name" value="Membership"/>
	    <display:setProperty name="paging.banner.items_name" value="Memberships"/>
	</display:table>
-->

</c:if>

<script type="text/javascript">
    document.personForm.firstName.focus();
    highlightTableRows("personList");
</script>

<v:javascript formName="person" cdata="false" dynamicJavascript="true" staticJavascript="false"/>
<script type="text/javascript"  src="<c:url value="/scripts/validator.jsp"/>"></script>
